package com.yedean.factory.context.annotation;

import cn.hutool.core.util.ClassUtil;
import com.yedean.factory.config.BeanDefinition;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * 提供查找带有@Component注解的类并添加到待注册的beanDefiniton集合中
 * @author HUAWEI
 */
public class ClasspathScanningCandidateComponentProvider {
    
    
    public Set<BeanDefinition> findCandidateComponents(String basePackage){
        Set<BeanDefinition> candidates=new LinkedHashSet<>();

        ClassUtil.scanPackageByAnnotation(basePackage,Component.class)
                .forEach(x->candidates.add(new BeanDefinition(x)));
        
        return candidates;
    }
}
